#include <php5/Zend/zend.h>

#include "php_droid.h"
#include <php5/ext/standard/php_array.h>

#if HAVE_DROID

static zend_class_entry *droid_ce;

PHP_METHOD(, __construct)
{
    zval* name;
    zval* age;
    zval* This = getThis();
    
    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &name, &age) == FAILURE) {
        RETURN_NULL();
    }
    zend_update_property(Z_OBJCE_P(This),This,"name",strlen("name"),name TSRMLS_CC);
    zend_update_property(Z_OBJCE_P(This),This,"age",strlen("age"),age TSRMLS_CC);
    zend_update_property(Z_OBJCE_P(This),This,"age1",strlen("age1"),age1 TSRMLS_CC);
    
    zval* slavik;
    slavik = "sd";
    php_printf("%s", "slavik1");    
    
}

PHP_METHOD(, getName)
{
    zval* name;
    zval* This = getThis();
    
    
    
    
    name = zend_read_property(Z_OBJCE_P(This),This,"name",strlen("name"),1 TSRMLS_CC); 
    
    RETURN_ZVAL(name,NULL,NULL);
}

PHP_METHOD(, setName)
{
    zval* name1;
    zval* This = getThis();
    
    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &name1) == FAILURE) {
        RETURN_NULL();
    }
    zend_update_property(Z_OBJCE_P(This),This,"name",strlen("name"),name1 TSRMLS_CC);
    
    
    
}

PHP_METHOD(, getAge)
{
    zval* age;
    zval* This = getThis();
    
    
    
    
    age = zend_read_property(Z_OBJCE_P(This),This,"age",strlen("age"),1 TSRMLS_CC); 
    
    RETURN_ZVAL(age,NULL,NULL);
}

PHP_METHOD(, setAge)
{
    zval* age1;
    zval* This = getThis();
    
    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &age1) == FAILURE) {
        RETURN_NULL();
    }
    zend_update_property(Z_OBJCE_P(This),This,"age",strlen("age"),age1 TSRMLS_CC);
    
    
    
}



zend_function_entry class_methods[] = {

{NULL, NULL, NULL}
}; 

/* {{{ droid_functions[] */
function_entry droid_functions[] = {
PHP_ME(,__construct,NULL, ZEND_ACC_PUBLIC)
PHP_ME(,getName,NULL, ZEND_ACC_PUBLIC)
PHP_ME(,setName,NULL, ZEND_ACC_PUBLIC)
PHP_ME(,getAge,NULL, ZEND_ACC_PUBLIC)
PHP_ME(,setAge,NULL, ZEND_ACC_PUBLIC)

{ NULL, NULL, NULL }
};

/* }}} */


/* {{{ droid_module_entry
*/
zend_module_entry droid_module_entry = {
STANDARD_MODULE_HEADER,
"droid",
class_methods,
PHP_MINIT(droid), /* Replace with NULL if there is nothing to do at php startup */ 
PHP_MSHUTDOWN(droid), /* Replace with NULL if there is nothing to do at php shutdown */
PHP_RINIT(droid), /* Replace with NULL if there is nothing to do at request start */
PHP_RSHUTDOWN(droid), /* Replace with NULL if there is nothing to do at request end */
PHP_MINFO(droid),
"0.0.1", 
STANDARD_MODULE_PROPERTIES
};
/* }}} */

#ifdef COMPILE_DL_DROID
ZEND_GET_MODULE(droid)
#endif


/* {{{ PHP_MINIT_FUNCTION */
PHP_MINIT_FUNCTION(droid)
{

/* add your stuff here */

zend_class_entry	stubClassEntry;

INIT_CLASS_ENTRY(stubClassEntry,"",droid_functions);
g_ClassEntry = zend_register_internal_class(&stubClassEntry TSRMLS_CC);

return SUCCESS;
}
/* }}} */


/* {{{ PHP_MSHUTDOWN_FUNCTION */
PHP_MSHUTDOWN_FUNCTION(droid)
{

/* add your stuff here */

return SUCCESS;
}
/* }}} */


/* {{{ PHP_RINIT_FUNCTION */
PHP_RINIT_FUNCTION(droid)
{
/* add your stuff here */

return SUCCESS;
}
/* }}} */


/* {{{ PHP_RSHUTDOWN_FUNCTION */
PHP_RSHUTDOWN_FUNCTION(droid)
{
/* add your stuff here */

return SUCCESS;
}
/* }}} */


/* {{{ PHP_MINFO_FUNCTION */
PHP_MINFO_FUNCTION(droid)
{

}
/* }}} */

#endif /* HAVE_DROID */
